using System;
using CookComputing.XmlRpc;
 
namespace JPOBlogger
{
    struct blog
    {
        public string url;
        public string blogid;
        public string blogName;
    }

    struct user
    {
        public string nickname;
        public string userid;
        public string url;
        public string email;
        public string lastname;
        public string firstname;
    }

    struct post
    {
        public string userid;
        public DateTime dateCreated;
        public string content;
        public string postid;
    }

    struct postList
    {
        //public string    authorName;
        public string    userid;
        public DateTime  dateCreated;
        public string    content;
        public string    postid;
        //public string    category;
    }

    //[XmlRpcUrl("http://saturno/~marble/marblestation/blog/xmlrpc.php")]
    class IBloggerApi : XmlRpcClientProtocol
    {

        [XmlRpcMethod("blogger.newPost")]
        public int newPost(string appkey, string blogid, string username, string password, string content, bool publish)
        {
            return (int)Invoke("newPost", new Object[] { appkey, blogid, username, password, content, publish });
        }

        [XmlRpcMethod("blogger.editPost")]
        public string editPost(string appkey, string postid, string username, string password, string content, bool publish)
        {
            return (string)Invoke("editPost", new Object[] { appkey, postid, username, password, content, publish });
        }

        [XmlRpcMethod("blogger.getUsersBlogs")]
        public blog[] getUsersBlog(string appkey, string username, string password)
        {
            return (blog[])Invoke("getUsersBlogs", new Object[] { appkey, username, password });
        }
        [XmlRpcMethod("blogger.getUserInfo")]
        public user getUserInfo(string appkey, string username, string password)
        {
            return (user)Invoke("getUserInfo", new Object[] { appkey, username, password });
        }

        [XmlRpcMethod("blogger.getTemplate")]
        public string getTemplate(string appkey, string blogid, string username, string password, string templateType)
        {
            return (string)Invoke("getTemplate", new Object[] { appkey, blogid, username, password, templateType });
        }

        [XmlRpcMethod("blogger.setTemplate")]
        public bool setTemplate(string appkey, string blogid, string username, string password, string template, string templateType)
        {
            return (bool)Invoke("setTemplate", new Object[] { appkey, blogid, username, password, template, templateType });
        }
        // Extra wordpress

        // unknown, newcontent & publish => ignored
        [XmlRpcMethod("blogger.deletePost")]
        public bool deletePost(bool unknown, string postid, string username, string password, string newcontent, bool publish)
        {
            return (bool)Invoke("deletePost", new Object[] { unknown, postid, username, password, newcontent, publish });
        }

        // 5 element?
        [XmlRpcMethod("blogger.getPost")]
        public post getPost(string appkey, string postid, string username, string password)
        {
            return (post)Invoke("getPost", new Object[] { appkey, postid, username, password });
        }

        [XmlRpcMethod("blogger.getRecentPosts")]
        public postList[] getRecentPosts(string appkey, string blogid, string username, string password, int numposts)
        {
            return (postList[])Invoke("getRecentPosts", new Object[] { appkey, blogid, username, password, numposts });
        }
    }
}